<?php


abstract class BasesfActualite extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $group_id;


	
	protected $titre;


	
	protected $texte;


	
	protected $created_at;


	
	protected $file_path;


	
	protected $enligne = false;


	
	protected $page_accueil = false;

	
	protected $asfGuardGroup;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getGroupId()
	{

		return $this->group_id;
	}

	
	public function getTitre()
	{

		return $this->titre;
	}

	
	public function getTexte()
	{

		return $this->texte;
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
						$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getFilePath()
	{

		return $this->file_path;
	}

	
	public function getEnligne()
	{

		return $this->enligne;
	}

	
	public function getPageAccueil()
	{

		return $this->page_accueil;
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = sfActualitePeer::ID;
		}

	} 
	
	public function setGroupId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->group_id !== $v) {
			$this->group_id = $v;
			$this->modifiedColumns[] = sfActualitePeer::GROUP_ID;
		}

		if ($this->asfGuardGroup !== null && $this->asfGuardGroup->getId() !== $v) {
			$this->asfGuardGroup = null;
		}

	} 
	
	public function setTitre($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->titre !== $v) {
			$this->titre = $v;
			$this->modifiedColumns[] = sfActualitePeer::TITRE;
		}

	} 
	
	public function setTexte($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->texte !== $v) {
			$this->texte = $v;
			$this->modifiedColumns[] = sfActualitePeer::TEXTE;
		}

	} 
	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = sfActualitePeer::CREATED_AT;
		}

	} 
	
	public function setFilePath($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->file_path !== $v) {
			$this->file_path = $v;
			$this->modifiedColumns[] = sfActualitePeer::FILE_PATH;
		}

	} 
	
	public function setEnligne($v)
	{

		if ($this->enligne !== $v || $v === false) {
			$this->enligne = $v;
			$this->modifiedColumns[] = sfActualitePeer::ENLIGNE;
		}

	} 
	
	public function setPageAccueil($v)
	{

		if ($this->page_accueil !== $v || $v === false) {
			$this->page_accueil = $v;
			$this->modifiedColumns[] = sfActualitePeer::PAGE_ACCUEIL;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->group_id = $rs->getInt($startcol + 1);

			$this->titre = $rs->getString($startcol + 2);

			$this->texte = $rs->getString($startcol + 3);

			$this->created_at = $rs->getTimestamp($startcol + 4, null);

			$this->file_path = $rs->getString($startcol + 5);

			$this->enligne = $rs->getBoolean($startcol + 6);

			$this->page_accueil = $rs->getBoolean($startcol + 7);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 8; 
		} catch (Exception $e) {
			throw new PropelException("Error populating sfActualite object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(sfActualitePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			sfActualitePeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isNew() && !$this->isColumnModified(sfActualitePeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(sfActualitePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->asfGuardGroup !== null) {
				if ($this->asfGuardGroup->isModified()) {
					$affectedRows += $this->asfGuardGroup->save($con);
				}
				$this->setsfGuardGroup($this->asfGuardGroup);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = sfActualitePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += sfActualitePeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->asfGuardGroup !== null) {
				if (!$this->asfGuardGroup->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->asfGuardGroup->getValidationFailures());
				}
			}


			if (($retval = sfActualitePeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = sfActualitePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getGroupId();
				break;
			case 2:
				return $this->getTitre();
				break;
			case 3:
				return $this->getTexte();
				break;
			case 4:
				return $this->getCreatedAt();
				break;
			case 5:
				return $this->getFilePath();
				break;
			case 6:
				return $this->getEnligne();
				break;
			case 7:
				return $this->getPageAccueil();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = sfActualitePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getGroupId(),
			$keys[2] => $this->getTitre(),
			$keys[3] => $this->getTexte(),
			$keys[4] => $this->getCreatedAt(),
			$keys[5] => $this->getFilePath(),
			$keys[6] => $this->getEnligne(),
			$keys[7] => $this->getPageAccueil(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = sfActualitePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setGroupId($value);
				break;
			case 2:
				$this->setTitre($value);
				break;
			case 3:
				$this->setTexte($value);
				break;
			case 4:
				$this->setCreatedAt($value);
				break;
			case 5:
				$this->setFilePath($value);
				break;
			case 6:
				$this->setEnligne($value);
				break;
			case 7:
				$this->setPageAccueil($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = sfActualitePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setTitre($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setTexte($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setFilePath($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setEnligne($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setPageAccueil($arr[$keys[7]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(sfActualitePeer::DATABASE_NAME);

		if ($this->isColumnModified(sfActualitePeer::ID)) $criteria->add(sfActualitePeer::ID, $this->id);
		if ($this->isColumnModified(sfActualitePeer::GROUP_ID)) $criteria->add(sfActualitePeer::GROUP_ID, $this->group_id);
		if ($this->isColumnModified(sfActualitePeer::TITRE)) $criteria->add(sfActualitePeer::TITRE, $this->titre);
		if ($this->isColumnModified(sfActualitePeer::TEXTE)) $criteria->add(sfActualitePeer::TEXTE, $this->texte);
		if ($this->isColumnModified(sfActualitePeer::CREATED_AT)) $criteria->add(sfActualitePeer::CREATED_AT, $this->created_at);
		if ($this->isColumnModified(sfActualitePeer::FILE_PATH)) $criteria->add(sfActualitePeer::FILE_PATH, $this->file_path);
		if ($this->isColumnModified(sfActualitePeer::ENLIGNE)) $criteria->add(sfActualitePeer::ENLIGNE, $this->enligne);
		if ($this->isColumnModified(sfActualitePeer::PAGE_ACCUEIL)) $criteria->add(sfActualitePeer::PAGE_ACCUEIL, $this->page_accueil);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(sfActualitePeer::DATABASE_NAME);

		$criteria->add(sfActualitePeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setGroupId($this->group_id);

		$copyObj->setTitre($this->titre);

		$copyObj->setTexte($this->texte);

		$copyObj->setCreatedAt($this->created_at);

		$copyObj->setFilePath($this->file_path);

		$copyObj->setEnligne($this->enligne);

		$copyObj->setPageAccueil($this->page_accueil);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new sfActualitePeer();
		}
		return self::$peer;
	}

	
	public function setsfGuardGroup($v)
	{


		if ($v === null) {
			$this->setGroupId(NULL);
		} else {
			$this->setGroupId($v->getId());
		}


		$this->asfGuardGroup = $v;
	}


	
	public function getsfGuardGroup($con = null)
	{
		if ($this->asfGuardGroup === null && ($this->group_id !== null)) {
						include_once 'plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroupPeer.php';

			$this->asfGuardGroup = sfGuardGroupPeer::retrieveByPK($this->group_id, $con);

			
		}
		return $this->asfGuardGroup;
	}

} 